const register = async() => {
    let username = document.querySelector('.username').value,
        password = document.querySelector('.password').value,
        email = document.querySelector('.email').value,
        mobile = document.querySelector('.mobile').value,
        gender_radios = document.querySelectorAll('.gender'),
        error_msg = document.querySelector('.error_msg'),
        gender;
    for (const radio of gender_radios) {
        if (radio.checked) {
            gender = radio.value
        }
    }
    if (!username || username.trim().length <= 0) error_msg.innerHTML = '请输入用户名'
    if (!password || password.trim().length <= 0) error_msg.innerHTML = '请输入密码';

    let response = await ajax('registeruser', 'POST', {
        username,
        password,
        gender,
        email,
        mobile
    })
    alert(response.meta.msg)
    location.href = './login.html'
}